package com.qf.controllrt;

import com.qf.config.AliyunProperties;
import com.qf.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private AliyunProperties aliyun;

    @GetMapping("/test")
    public String test(){
        return "hello SpringBoot , 基本";
    }

    @Resource(name = "user1")
    private User user;


    @RequestMapping("/hello")
    public String test1() {
        System.out.println(user);
        System.out.println(aliyun);
        return "Hello SpringBoot!";
    }

    //读取自定义配置
    @Value("${aliyun.username}")
    private String aliyunName;
    @Value("${aliyun.ip}")
    private String aliyunIp;
    @GetMapping("/a1")
    public String customValue() {
        System.out.println("minng"+aliyunName+"ip"+aliyunIp);
        return "ming"+aliyunName+"ip"+aliyunIp;
    }
}

